$(document).ready(function() {
	MyObjectHHH = {
		infonumber : "",
		infoname : "",
		price : "",
		offset : 0,
		limit : 10,
		uid : $("#useridoflogin").val()
		/*uid : 23*/
	}
	
	function getlist() {
		MyObjectHHH.infonumber = $("#infonumber").val();
		MyObjectHHH.infoname = $("#infoname").val();
		MyObjectHHH.price = $("#pirce").val();
	}

	/*O(∩_∩)O*/
	MyObjectogHHH = {
		/*url :"http://localhost/ix/controllistportofsecond",
		uid:23,*/
		url :Server+ "/ix/controllistportofsecond",
		uid:$("#useridoflogin").val(),
		infonumber:$("#infonumber").val(),
		infoname:$("#infoname").val(),
		price:$("#pirce").val(),
		offset : 0,
		limit : 10,
		haveuid : "",
		ishavesend : 1,
		boolean : false,
		type : "POST",
		dataType : "JSON",
		number : 1,
		AllCount : 0,
		nowp : 0,
		Callback : function(nowPage) {
			MyObjectogHHH.nowp = nowPage;
			MyObjectHHH.offset = nowPage-1;
		
			getlist();
			Myload(MyObjectHHH);
		}
	};

	function MyObjectogHHHofpageload() {
		$("#page").initPage((function() {
			$.ajax({
				"url" : Server+ "/ix/controllistportofsecond",
				"type" : MyObjectogHHH.type,
				"dataType" : MyObjectogHHH.dataType,
				"async" : MyObjectogHHH.boolean,
				"data" : MyObjectHHH,
				success : function(data) {
					MyObjectogHHH.AllCount = data.count;
				}
			});
			return MyObjectogHHH.AllCount;
		})(), MyObjectogHHH.number, MyObjectogHHH.Callback);
	}
	MyObjectogHHHofpageload();
	

	$("#findinfolist").click(function(){
		getlist();
		Myload(MyObjectHHH);
	})
	/*$("#listdiv")
		.change(function(){
			getlist();
			Myload(MyObjectHHH);
		})
		.keydown(function(){
			getlist();
			Myload(MyObjectHHH);
		})
		.bind('input', function() {
			getlist();
			MyObjectogHHHofpageload();
		});*/
})





function Myload(MyObjectHHH) {
	$.ajax({
		/*url :"http://localhost/ix/controllistportofsecond",*/
		url :Server+ "/ix/controllistportofsecond",
		type : "POST",
		dataType : "JSON",
		data : MyObjectHHH,
		success : function(data) {
			var html = "";
			var htmlhead = '<tr>\
				<th>仪器编号</th>\
				<th>仪器名称</th>\
				<th>仪器负责人</th>\
				<th>仪器状态</th>\
				<th>开机预热时长</th>\
				<th>运行时间</th>\
				<th>运行状态</th>\
				<th>发布状态</th>\
				<th>操作</th>\
			</tr>';
			for (var i = 0; i < data.list.length; i++) {
				var pattern = '<tr>\
					<td>#0</td>\
					<td>#1</td>\
					<td>#2</td>\
					<td>#3</td>\
					<td>#4</td>\
					<td>#5</td>\
					<td>#6</td>\
					<td>#7</td>\
					<td>\
						<a onclick="havelook(#9)">查看</a>\
					</td>\
				</tr>';
				html += pattern
					.replace("#0", data.list[i].siiNumber)
					.replace("#1", data.list[i].siiChineseName)
					.replace("#2", data.list[i].realname)
					.replace("#3", function(){
						switch(data.list[i].siiInsStatus){
							case 0: return "正常";
							case 1: return "损坏";
							case 2: return "需更换耗材";
							default: return "仪器正常";
						}
					})
					.replace("#4", function(){
						/*data.list[i].siiBootUpTime*/
						return "1min"
					})
					.replace("#5", data.list[i].siiServiceTime)
					.replace("#6", function(){
						switch(data.list[i].siiRunStatus){
							case 0: return "开机";
							case 1: return "使用中";
							case 2: return "关机";
						}
					})
					.replace("#7", data.list[i].siiIStatus)
					.replace("#9", data.list[i].siiId)
			}

			$("#listtableofsecond").html(htmlhead + html);
		},
	})
}






function havelook(infoid){
	$(location).attr('href', 'lizisepuyimy16-8?infoid=' + infoid);
}



/*function findInfo(id){
	$(location).attr('href', 'lizisepuyi16?id=' + id + '');
}
function knowledge(id){
	$(location).attr('href', 'send_machine18_1?id=' + id + '');
}*/